package main

import "fmt"

func main() {

	// 方式一：字面量

	var m map[string]int = map[string]int{
		"红烧肉": 1,
		"清蒸鱼": 2,
		"溜大虾": 3,
		"鲍鱼饭": 4,
	}

	fmt.Println(m)

	// 方式二：使用内置函数make①

	foodsMap := make(map[string]int)
	foodsMap["红烧肉"] = 22
	foodsMap["清蒸鱼"] = 33
	foodsMap["溜大虾"] = 44
	foodsMap["鲍鱼饭"] = 55

	fmt.Println(foodsMap)

	foodsMap2 := make(map[string]int, 10)
	foodsMap2["红烧肉"] = 22
	foodsMap2["清蒸鱼"] = 33
	foodsMap2["溜大虾"] = 44
	foodsMap2["鲍鱼饭"] = 55

	fmt.Println(foodsMap2)

	// 遍历
	for k, v := range foodsMap2 {
		fmt.Printf("菜品：%s, 价格：%d", k, v)
	}
}
